//
//  MSUser.m
//  MSJD
//
//  Created by 箭军刘 on 2018/10/23.
//  Copyright © 2018年 xiangbo. All rights reserved.
//

#import "MSUser.h"


NSString *const kMSUserUserId = @"uid";
NSString *const kMSUserToken = @"token";
NSString *const kMSUserUserName = @"username";
NSString *const kMSUserGender = @"gender";
NSString *const kMSUserAvatar = @"avatar";
NSString *const kMSUserOpenId = @"uuid";
NSString *const kMSUserPhone = @"phone";

NSString *const kMSUserLon = @"lon";
NSString *const kMSUserLat = @"lat";

@interface MSUser()<NSCopying, NSCoding>

@end

@implementation MSUser

+ (NSDictionary *)modelCustomPropertyMapper {
    return @{@"userId":@"id"};
}

- (void)encodeWithCoder:(NSCoder *)aCoder {
    [aCoder encodeObject:self.userId forKey:kMSUserUserId];
    [aCoder encodeObject:self.token forKey:kMSUserToken];
    [aCoder encodeObject:self.username forKey:kMSUserUserName];
    [aCoder encodeObject:self.gender forKey:kMSUserGender];
    [aCoder encodeObject:self.avatar forKey:kMSUserAvatar];
    [aCoder encodeObject:self.uuid forKey:kMSUserOpenId];
    [aCoder encodeObject:self.phone forKey:kMSUserPhone];
    [aCoder encodeObject:self.lon forKey:kMSUserLon];
    [aCoder encodeObject:self.lat forKey:kMSUserLat];
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder {
    self = [super init];
    
    self.userId = [aDecoder decodeObjectForKey:kMSUserUserId];
    self.token = [aDecoder decodeObjectForKey:kMSUserToken];
    self.username = [aDecoder decodeObjectForKey:kMSUserUserName];
    self.gender = [aDecoder decodeObjectForKey:kMSUserGender];
    self.avatar = [aDecoder decodeObjectForKey:kMSUserAvatar];
    self.uuid = [aDecoder decodeObjectForKey:kMSUserOpenId];
    self.phone = [aDecoder decodeObjectForKey:kMSUserPhone];
    
    self.lon = [aDecoder decodeObjectForKey:kMSUserLon];
    self.lat = [aDecoder decodeObjectForKey:kMSUserLat];
    
    return self;
}

- (instancetype)copyWithZone:(NSZone *)zone {
    MSUser *copy = [MSUser new];
    
    copy.userId = [self.userId copy];
    copy.token = [self.token copy];
    copy.username = [self.username copy];
    copy.gender = [self.gender copy];
    copy.avatar = [self.avatar copy];
    copy.uuid = [self.uuid copy];
    copy.phone = [self.phone copy];
    
    copy.lon = [self.lon copy];
    copy.lat = [self.lat copy];
    
    return copy;
}

@end
